using System;
using System.Collections;
using System.Data;
using PCSComProduction.DCP.DS;
using PCSComUtils.Common;
using PCSComUtils.Common.DS;

using PCSComUtils.PCSExc;

namespace PCSComProduction.DCP.BO
{
	public class DCPReportBO //:  IDCPReportBO
	{
		public DCPReportBO()
		{
			
		}

		/// <summary>
		/// Insert a new record into database
		/// </summary>
		//[AutoComplete(true)]
		public void Add(object pObjectDetail)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// Delete record by condition
		/// </summary>
		//[AutoComplete(true)]
		public void Delete(object pObjectVO)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// Get the object information by ID of VO class
		/// </summary>
		//[AutoComplete(true)]
		public object GetObjectVO(int pintID, string VOclass)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// Return the DataSet (list of record) by inputing the FieldList and Condition
		/// </summary>
		//[AutoComplete(true)]
		public void UpdateDataSet(DataSet dstData)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// Update into Database
		/// </summary>
		//[AutoComplete(true)]
		public void Update(object pObjectDetail)
		{
			throw new NotImplementedException();
		}
		/// <summary>
		/// Gets Net begin quantity of a list of item
		/// </summary>
		/// <param name="pstrItems">List of Item</param>
		/// <param name="pstrMasterLocation">List of Master Location</param>
		/// <returns>DataTable</returns>
		//[AutoComplete(true)]
		public DataTable GetNetBeginQuantity(string pstrItems, string pstrMasterLocation)
		{
			try
			{
				DCPReportDS dsDCPReport = new DCPReportDS();
				return dsDCPReport.GetBeginNetQuantity(pstrItems, pstrMasterLocation);
			}
			catch (PCSDBException ex)
			{
				throw ex;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		/// <summary>
		/// Gets Cycle Detail from Master
		/// </summary>
		/// <param name="pintCycleMasterID">Cycle Master ID</param>
		/// <returns>Cycle Detail</returns>
		//[AutoComplete(true)]
		public DataTable GetCycleDetail(int pintCycleMasterID)
		{
			PRO_DCOptionDetailDS dsDetail = new PRO_DCOptionDetailDS();
			return dsDetail.GetDetailByMaster(pintCycleMasterID).Tables[0];
		}
		/// <summary>
		/// Gets all Production Line
		/// </summary>
		/// <param name="pintCCNID">CCN</param>
		/// <returns>DataTable</returns>
		//[AutoComplete(true)]
		public DataTable GetAllProductionLine(int pintCCNID)
		{
			PRO_ProductionLineDS dsProductionLine = new PRO_ProductionLineDS();
			return dsProductionLine.List(pintCCNID);
		}
		/// <summary>
		/// Gets the total In transaction of inventory
		/// </summary>
		/// <param name="pstrItems">List of Items</param>
		/// <param name="pstrMasterLocation">List of Master Locations</param>
		/// <param name="pdtmFromDate">From Date</param>
		/// <param name="pdtmToDate">To Date</param>
		/// <returns>DataTable</returns>
		//[AutoComplete(true)]
		public DataTable GetTotalIn(string pstrItems, string pstrMasterLocation, DateTime pdtmFromDate, DateTime pdtmToDate)
		{
			DCPReportDS dsDCPReport = new DCPReportDS();
			return dsDCPReport.GetTotalIn(pstrItems, pstrMasterLocation, pdtmFromDate, pdtmToDate);
		}
		/// <summary>
		/// Gets the total Out transaction of inventory
		/// </summary>
		/// <param name="pstrItems">List of Items</param>
		/// <param name="pstrMasterLocation">List of Master Locations</param>
		/// <param name="pdtmFromDate">From Date</param>
		/// <param name="pdtmToDate">To Date</param>
		/// <returns>DataTable</returns>
		//[AutoComplete(true)]
		public DataTable GetTotalOut(string pstrItems, string pstrMasterLocation, DateTime pdtmFromDate, DateTime pdtmToDate)
		{
			DCPReportDS dsDCPReport = new DCPReportDS();
			return dsDCPReport.GetTotalOut(pstrItems, pstrMasterLocation, pdtmFromDate, pdtmToDate);
		}

		//[AutoComplete(true)]
		public DataTable GetTotalSO(string pstrItems, string pstrMasterLocation, DateTime pdtmFromDate, DateTime pdtmToDate)
		{
			DCPReportDS dsDCPReport = new DCPReportDS();
			return dsDCPReport.GetTotalSO(pstrItems, pstrMasterLocation, pdtmFromDate, pdtmToDate);
		}

		//[AutoComplete(true)]
		public DataTable GetTotalPO(string pstrItems, string pstrMasterLocation, DateTime pdtmFromDate, DateTime pdtmToDate)
		{
			DCPReportDS dsDCPReport = new DCPReportDS();
			return dsDCPReport.GetTotalPO(pstrItems, pstrMasterLocation, pdtmFromDate, pdtmToDate);
		}

		//[AutoComplete(true)]
		public DataTable GetTotalWO(string pstrCCNID)
		{
			DCPReportDS dsDCPReport = new DCPReportDS();
			return dsDCPReport.GetTotalWO(pstrCCNID);
		}

		/// <summary>
		/// Gets working time of work center
		/// </summary>
		/// <param name="pintProductionLineID">Production Line</param>
		/// <returns>DataTable</returns>
		//[AutoComplete(true)]
		public DataTable GetWorkingTime(int pintProductionLineID)
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetWorkingTime(pintProductionLineID);
		}
		/// <summary>
		/// Gets working time of work center
		/// </summary>
		/// <returns>DataTable</returns>
		//[AutoComplete(true)]
		public DataTable GetWorkingTime()
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetWorkingTime();
		}
		public ArrayList GetWorkingDayByYear(int pintYear)
		{
			UtilsDS dsUtil = new UtilsDS();
			return dsUtil.GetWorkingDayByYear(pintYear);
		}
		public ArrayList GetHolidaysInYear(int pintYear)
		{
			UtilsDS dsUtils = new UtilsDS();
			return dsUtils.GetHolidaysInYear(pintYear);
		}
		//[AutoComplete(true)]
		public DataTable ListProductionLine()
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.ListProductionLine();
		}
		//[AutoComplete(true)]
		public DataTable ListProduct(string pstrCCNID, string pstrProductionLineList)
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.ListProduct(pstrCCNID, pstrProductionLineList);
		}
		//[AutoComplete(true)]
		public DataTable GetPlanningOffset(string pstrCCNID)
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetPlanningOffset(pstrCCNID);
		}

		//[AutoComplete(true)]
		public DataTable GetBeginStockForReportData()
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetBeginStockForReportData();
		}

		//[AutoComplete(true)]
		public DataTable GetBeginNetQuantity(string pstrCCNID)
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetBeginNetQuantity(pstrCCNID);
		}
		//[AutoComplete(true)]
		public DataTable GetTransactionHistory()
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetTransactionHistory();
		}
		//[AutoComplete(true)]
		public DataTable GetDeliveryForSO()
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetDeliveryForSO();
		}
		//[AutoComplete(true)]
		public DataTable GetProduce()
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetProduce();
		}
		//[AutoComplete(true)]
		public DataTable GetDeliveryForParent(string pstrCCNID)
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetDemandWO(pstrCCNID);
		}
		//[AutoComplete(true)]
		public DataTable GetDeliveryForParent()
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetDeliveryForParent();
		}
		//[AutoComplete(true)]
		public DataTable GetWorkingDateFromWCCapacity()
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetWorkingDateFromWCCapacity();
		}
		//[AutoComplete(true)]
		public DataTable GetWorkingDateFromWCCapacity(int pintProductionLineID)
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetWorkingDateFromWCCapacity(pintProductionLineID);
		}
		//[AutoComplete(true)]
		public ArrayList GetPlanningPeriod(string pstrCCNID)
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetPlanningPeriod(pstrCCNID);
		}
		//[AutoComplete(true)]
		public DataTable GetCycles(string pstrCCNID)
		{
			DCPReportDS dsReport = new DCPReportDS();
			return dsReport.GetCycles(pstrCCNID);
		}
		//[AutoComplete(true)]
		public void UpdateBeginStockData(DataSet pdstData)
		{
			DCPReportDS dsReport = new DCPReportDS();
			dsReport.UpdateBeginStockData(pdstData);
		}
		//[AutoComplete(true)]
		public object GetCyclerMasterObject(int pintMasterID)
		{
			PRO_DCOptionMasterDS dsOption = new PRO_DCOptionMasterDS();
			DataRow drowData = dsOption.GetDCOptionMaster(pintMasterID);
			PRO_DCOptionMasterVO voOption = new PRO_DCOptionMasterVO();
			try
			{
				voOption.DCOptionMasterID = Convert.ToInt32(drowData[PRO_DCOptionMasterTable.DCOPTIONMASTERID_FLD]);
			}
			catch{}
			try
			{
				voOption.AsOfDate = Convert.ToDateTime(drowData[PRO_DCOptionMasterTable.ASOFDATE_FLD]);
			}
			catch{}
			try
			{
				voOption.UseCacheAsBegin = Convert.ToBoolean(drowData[PRO_DCOptionMasterTable.USECACHE_ASBEGIN_FLD]);
			}
			catch{}
			voOption.CCNID = Convert.ToInt32(drowData[PRO_DCOptionMasterTable.CCNID_FLD]);
			try
			{
				voOption.LastUpdate = Convert.ToDateTime(drowData[PRO_DCOptionMasterTable.LASTUPDATE_FLD]);
			}
			catch{}
			try
			{
				voOption.PlanHorizon = Convert.ToInt32(drowData[PRO_DCOptionMasterTable.PLANHORIZON_FLD]);
			}
			catch{}
			try
			{
				voOption.PlanningPeriod = Convert.ToDateTime(drowData[PRO_DCOptionMasterTable.PLANNINGPERIOD_FLD]);
			}
			catch{}
			try
			{
				voOption.Version = Convert.ToInt32(drowData[PRO_DCOptionMasterTable.VERSION_FLD]);
			}
			catch{}
			return voOption;
		}

		/// <summary>
		/// Get begin data of cycle
		/// </summary>
		/// <param name="pintCycleId"></param>
		/// <returns></returns>
		//[AutoComplete(true)]
		public DataTable GetBeginData(int pintCycleId)
		{
			PRO_DCOptionMasterDS dsDCOptionMaster = new PRO_DCOptionMasterDS();
			return dsDCOptionMaster.GetBeginData(pintCycleId);
		}
	}
}